<template>
	<view>
		<view v-for="(item,i) in this.$store.state.goodsbuyList" class="buy-box">
			<!-- 选择框 -->
			<view class="buy-check">
				<checkbox-group>
				    <label>
				         <checkbox value="cb" :checked="item.ischeck" color="#FFCC33" style="transform:scale(0.7)" @click="gocheck(item,i)"/>
				    </label>
				</checkbox-group>
			</view>
			<!-- 图片 -->
			<view class="buy-img">
				<image :src="item.img" mode="scaleToFill"></image>
			</view>
			<!-- 信息 -->
			<view class="buy-message">
				<view class="buy-title">{{item.title}}</view>
				<view class="buy-title-count">
					<view class="buy-price">{{item.lowNowPrice}}</view>
					<view class="buy-count">{{item.count}}</view>
				</view>
			</view>
		</view>
		<view class="count-box" >
			<view>总计：{{allCount}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isok:''
			}
		},
		onLoad() {
			this.testList = this.$store.state.goodsbuyList

		},
		computed:{
			allCount(){
				return this.$store.state.goodsbuyList.reduce((a,item)=>{
					if(item.ischeck){
						return a+ item.lowNowPrice*item.count
					}
					
				},0)
			}
		},
		methods: {
			gocheck(item,i){
				item.ischeck =! item.ischeck
			
				this.isok =this.$store.state.goodsbuyList[i].ischeck
				
				console.log(item.ischeck)
				console.log(item)
				console.log(this.$store.state.goodsbuyList)
			},
			
		}
	}
</script>

<style>
@import url("./find.css");
</style>
